import java.util.HashMap;


public abstract class ClockService {

	private static ClockService clock = null;
	protected TimeStamp ts;
	
	public static ClockService getClock(String clockType, HashMap<String, Node> nodes, String local_name) {
		if(clock == null){
			if(clockType.equals("Logical")){
				clock = new Logical(local_name);
			}
			else if(clockType.equals("Vector")){
				clock = new Vector(nodes, local_name);
			}
		}
		return clock;
	}

	public  void increase(){
		ts.increase();
	}

	public void assign(TimeStampedMessage message) {
		message.setTs(ts);
	}

	public void showTime() {
		ts.show();
	}

	public void update(TimeStampedMessage m){
		ts.update(m.getTs());
	}
		

}
